package LeetCode;

import java.util.List;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}14:26
 */
public class LeetCode141 {

    class ListNode {
     int val;
      ListNode next;
      ListNode(int x) {
          val = x;
          next = null;
      }
  }


    public boolean hasCycle(ListNode head) {
        if (head == null){
            return false;
        }
        ListNode fast = head.next;
        ListNode last = head;
        while (fast != last){
            if (fast.next==null || fast == null){
                return false;
            }
            last = last.next;
            fast = fast.next.next;
        }
        return true;
    }
}
